<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据管理后台</title>
    <style>
        body { background: #222; color: #fff; font-family: Arial; }
        h1 { text-align: center; }
        .section { margin: 2rem auto; width: 90%; max-width: 900px; background: #333; border-radius: 8px; padding: 1rem; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
        th, td { border: 1px solid #444; padding: 0.5rem; text-align: center; }
        th { background: #444; }
        input, select { padding: 0.3rem; border-radius: 4px; border: 1px solid #888; }
        .form-row { margin-bottom: 1rem; }
        .form-row label { display: inline-block; width: 120px; }
        .form-row input, .form-row select { width: 180px; }
        .form-row button { margin-left: 10px; }
        .form-title { font-weight: bold; margin-bottom: 0.5rem; }
    </style>
</head>
<body>
    <h1>德州市大数据管理后台</h1>
    <div class="section">
        <div class="form-title">新增就业数据</div>
        <form method="post" action="/add_employment">
            <div class="form-row">
                <label>日期：</label>
                <input type="month" name="month" value="{{current_month}}">
            </div>
            <div class="form-row">
                <label>姓名：</label>
                <input type="text" name="name" required>
                <label>年龄：</label>
                <input type="number" name="age" min="16" max="60" required>
                <label>学历：</label>
                <select name="education">
                    <option>博士</option>
                    <option>硕士</option>
                    <option>本科</option>
                    <option>大专</option>
                    <option>中专</option>
                    <option>高中</option>
                </select>
                <button type="submit">新增</button>
            </div>
        </form>
        <table>
            <tr><th>月份</th><th>姓名</th><th>年龄</th><th>学历</th></tr>
            {% for item in employment_data %}
                <tr><td>{{item.month}}</td><td>{{item.name}}</td><td>{{item.age}}</td><td>{{item.education}}</td></tr>
            {% endfor %}
        </table>
        <div class="pagination">
            {% set total_pages = (employment_total // page_size) + (1 if employment_total % page_size > 0 else 0) %}
            {% if total_pages > 1 %}
                <span>页码：</span>
                {% for p in range(1, total_pages+1) %}
                    {% if p == employment_page %}
                        <strong>{{p}}</strong>
                    {% else %}
                        <a href="?employment_page={{p}}&enterprise_page={{enterprise_page}}&training_page={{training_page}}&activity_page={{activity_page}}&incubation_page={{incubation_page}}">{{p}}</a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </div>
    <div class="section">
        <div class="form-title">新增企业数据</div>
        <form method="post" action="/add_enterprise">
            <div class="form-row">
                <label>日期：</label>
                <input type="month" name="month" value="{{current_month}}">
            </div>
            <div class="form-row">
                <label>企业名称：</label>
                <input type="text" name="name" required>
                <label>地区：</label>
                <input type="text" name="district" required>
                <label>需求岗位：</label>
                <input type="text" name="job" required>
                <button type="submit">新增</button>
            </div>
        </form>
        <table>
            <tr><th>月份</th><th>企业名称</th><th>地区</th><th>需求岗位</th></tr>
            {% for item in enterprise_data %}
                <tr><td>{{item.month}}</td><td>{{item.name}}</td><td>{{item.district}}</td><td>{{item.job}}</td></tr>
            {% endfor %}
        </table>
        <div class="pagination">
            {% set total_pages = (enterprise_total // page_size) + (1 if enterprise_total % page_size > 0 else 0) %}
            {% if total_pages > 1 %}
                <span>页码：</span>
                {% for p in range(1, total_pages+1) %}
                    {% if p == enterprise_page %}
                        <strong>{{p}}</strong>
                    {% else %}
                        <a href="?employment_page={{employment_page}}&enterprise_page={{p}}&training_page={{training_page}}&activity_page={{activity_page}}&incubation_page={{incubation_page}}">{{p}}</a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </div>
    <div class="section">
        <div class="form-title">新增培训数据</div>
        <form method="post" action="/add_training">
            <div class="form-row">
                <label>日期：</label>
                <input type="month" name="month" value="{{current_month}}">
            </div>
            <div class="form-row">
                <label>姓名：</label>
                <input type="text" name="name" required>
                <label>年龄：</label>
                <input type="number" name="age" min="16" max="60" required>
                <label>学历：</label>
                <select name="education">
                    <option>博士</option>
                    <option>硕士</option>
                    <option>本科</option>
                    <option>大专</option>
                    <option>中专</option>
                    <option>高中</option>
                </select>
                <label>培训内容：</label>
                <input type="text" name="content" required>
                <button type="submit">新增</button>
            </div>
        </form>
        <table>
            <tr><th>月份</th><th>姓名</th><th>年龄</th><th>学历</th><th>培训内容</th></tr>
            {% for item in training_data %}
                <tr><td>{{item.month}}</td><td>{{item.name}}</td><td>{{item.age}}</td><td>{{item.education}}</td><td>{{item.content}}</td></tr>
            {% endfor %}
        </table>
        <div class="pagination">
            {% set total_pages = (training_total // page_size) + (1 if training_total % page_size > 0 else 0) %}
            {% if total_pages > 1 %}
                <span>页码：</span>
                {% for p in range(1, total_pages+1) %}
                    {% if p == training_page %}
                        <strong>{{p}}</strong>
                    {% else %}
                        <a href="?employment_page={{employment_page}}&enterprise_page={{enterprise_page}}&training_page={{p}}&activity_page={{activity_page}}&incubation_page={{incubation_page}}">{{p}}</a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </div>
    <div class="section">
        <div class="form-title">新增组织活动数据</div>
        <form method="post" action="/add_activity">
            <div class="form-row">
                <label>日期：</label>
                <input type="month" name="month" value="{{current_month}}">
            </div>
            <div class="form-row">
                <label>活动名称：</label>
                <input type="text" name="name" required>
                <label>活动人数：</label>
                <input type="number" name="count" min="1" required>
                <button type="submit">新增</button>
            </div>
        </form>
        <table>
            <tr><th>月份</th><th>活动名称</th><th>活动人数</th></tr>
            {% for item in activity_data %}
                <tr><td>{{item.month}}</td><td>{{item.name}}</td><td>{{item.count}}</td></tr>
            {% endfor %}
        </table>
        <div class="pagination">
            {% set total_pages = (activity_total // page_size) + (1 if activity_total % page_size > 0 else 0) %}
            {% if total_pages > 1 %}
                <span>页码：</span>
                {% for p in range(1, total_pages+1) %}
                    {% if p == activity_page %}
                        <strong>{{p}}</strong>
                    {% else %}
                        <a href="?employment_page={{employment_page}}&enterprise_page={{enterprise_page}}&training_page={{training_page}}&activity_page={{p}}&incubation_page={{incubation_page}}">{{p}}</a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </div>
    <div class="section">
        <div class="form-title">新增孵化创业项目数据</div>
        <form method="post" action="/add_incubation">
            <div class="form-row">
                <label>日期：</label>
                <input type="month" name="month" value="{{current_month}}">
            </div>
            <div class="form-row">
                <label>项目名称：</label>
                <input type="text" name="name" required>
                <label>所属行业：</label>
                <input type="text" name="industry" required>
                <button type="submit">新增</button>
            </div>
        </form>
        <table>
            <tr><th>月份</th><th>项目名称</th><th>所属行业</th></tr>
            {% for item in incubation_data %}
                <tr><td>{{item.month}}</td><td>{{item.name}}</td><td>{{item.industry}}</td></tr>
            {% endfor %}
        </table>
        <div class="pagination">
            {% set total_pages = (incubation_total // page_size) + (1 if incubation_total % page_size > 0 else 0) %}
            {% if total_pages > 1 %}
                <span>页码：</span>
                {% for p in range(1, total_pages+1) %}
                    {% if p == incubation_page %}
                        <strong>{{p}}</strong>
                    {% else %}
                        <a href="?employment_page={{employment_page}}&enterprise_page={{enterprise_page}}&training_page={{training_page}}&activity_page={{activity_page}}&incubation_page={{p}}">{{p}}</a>
                    {% endif %}
                {% endfor %}
            {% endif %}
        </div>
    </div>
</body>
</html>
